#!/usr/bin/python -S
"""
log.py
"""

__author__ = 'Andy Chu'


import sys


# TODO: Maybe show a (single) warning if there is no longer installed.  The
# user can call log.NoLogging() to suppress this.

def trace(msg, *args):
  #raise RuntimeError('InstallLogger() not called')
  pass


def log_to_stderr(msg, *args):
  if args:
    msg = msg % args
  # leading tab to make it stand out
  print >>sys.stderr, '\t' + msg


def install_default_logger():
  global trace
  trace = log_to_stderr


def install_logger(func):
  global trace
  trace = func
InstallLogger = install_logger  # backward compat

